package org.zfes.snowier.cloud.zbss.layer.tc.biz.controller;

import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.core.util.ZStrUtil;
import org.zfes.snowier.web.annos.ListParam;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.cloud.zbss.layer.tc.biz.model.Practitioner;
import org.zfes.snowier.cloud.zbss.layer.tc.biz.service.IPractitionerService;
@Controller 
@RequestMapping("/tcms/practitioner")
public class PractitionerController extends BaseController {

	private String viewPathPrefix="/tcms";
	
	@Autowired
	private IPractitionerService practitionerService;

	@RequestMapping(value={"/",""}, method = RequestMethod.GET,produces = MediaType.TEXT_HTML_VALUE)
    public Object index(){
		return forward(viewPathPrefix,"practitioner.html");
    }
	
	//@RequiresPermissions(value="practitioner:loadPractitionerList",desc="执业人员列表")
    @RequestMapping(value="/loadPractitionerDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadPractitionerDataSet(@RequestParam Map<String,Object> params){
	    DataSet dataSet=  practitionerService.loadPractitionerDataSet(params);
	    return dataSet;
    }
	
	//@RequiresPermissions(value="practitioner:addPractitioner",desc="执业人员添加")
    @RequestMapping(value="/addPractitioner", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public  @ResponseBody Object addPractitioner(Practitioner practitioner){
		practitionerService.createPractitioner(practitioner);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
	//@RequiresPermissions(value="practitioner:loadPractitioner",desc="执业人员加载")
    @RequestMapping(value="/loadPractitioner", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadPractitioner(Long id){
		Optional<Practitioner> ops = practitionerService.loadPractitionerById(id);
		return ajaxQuery("practitioner",ops);
    }
	
	//@RequiresPermissions(value="practitioner:updatePractitioner",desc="执业人员更新")
    @RequestMapping(value="/updatePractitioner", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object updatePractitioner(Practitioner practitioner){
		practitionerService.updatePractitioner(practitioner);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
	//@RequiresPermissions(value="practitioner:deletPractitioner",desc="执业人员删除")
//    @RequestMapping(value="/deletPractitioner", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
//    public @ResponseBody  Object deletPractitioner(Long id){
//		practitionerService.deletPractitioner(id);
//		return ajaxDoneSuccess("数据操作成功 ");
//    }
    @RequestMapping(value="/setPractitionerEnabled", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object setPractitionerEnabled(@ListParam(Long.class)List<Long> ids,Boolean  enabled){
    	practitionerService.setEnabled(ids,enabled);
		return ajaxDoneSuccess("数据操作成功 ");
    }
}